import request from "@/utils/request.js";

//获取购物车商品
export const reqShopCarList = () => {
    return request({
        url:"/api/shopcar/getShopCarList",
        method:"get"
    })
}

//删除购物车中某个课程
export function reqDeleteShopCartCourse(params,token){
    return request({
        url:"/api/shopcar/deleteShopCar",
        method:"get",
        params,
        headers:{token}
    })
}

//批量删除购物车中课程 (参数 ids:[课程id,课程id,...],token:临时token)
export function reqDeleteShopCartCourses(ids,token){
    return request({
        url:"/api/shopcar/deleteShopCars",
        method:"post",
        data:ids,
        headers:{token}
    })
}

//添加课程到购物车
export const reqAddShopCarCourse = (data,token) => {
    return request({
        url:"/api/shopcar/addShopCar",
        method:"post",
        data,
        headers:{token:token}
    })
}

//去结算获取结算商品信息
export const reqOrderCourse = (data) => {
    return request({
        url:"/api/order/settlement",
        method:"post",
        data
    })
}

//结算付款api
export const reqPayment = (data,method) => {
    if(method == 'weixin'){
        return request({
            url:"/api/pay/wxpay/createOrder",
            method:"post",
            data
        })
    }else if(method == 'zhifubao'){
        return request({
            url:"/api/pay/alipay/createOrder",
            method:"post",
            data
        })
    }
}

//查询支付宝订单状态
export function reqZhifubaoOrderState(orderNumber){
    return request({
        url:"/api/pay/alipay/queryOrder",
        method:"get",
        params:orderNumber
    })
}

//查询微信订单状态
export function reqWeixinOrderState(orderNumber){
    return request({
        url:"/api/pay/wxpay/queryOrder",
        method:"get",
        params:orderNumber
    })
}